import { Injectable } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { ArticleService } from 'src/article/article.service';

@Injectable()
export class TaskService {
  constructor(private readonly articleService: ArticleService) {}

  // 这里设置的是每5分钟执行一次，请其实可以自定义，比如说设置晚上4点执行，或者设置每个月的1号执行
  @Cron(CronExpression.EVERY_5_MINUTES)
  getTasks() {
    this.articleService.refreshToDB();
  }
}
